package entitybeans;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity(name = "Convenio")
@Table(name = "TB_CONV_MEDI")
public class ConvenioEntity {
	@Id
	@Column(name = "CD_CONV_MEDI")
	private int id;
	@Column(name = "NM_CONV_MEDI")
	private String nome;
	@OneToMany(mappedBy = "convenio")
	private List<PlanoSaudeEntity> planosSaude;

	public List<PlanoSaudeEntity> getPlanosSaude() {
		return planosSaude;
	}

	public void addPlanoSaude(PlanoSaudeEntity planoSaudeEntity) {
		planoSaudeEntity.setConvenio(this);
		this.planosSaude.add(planoSaudeEntity);
	}

	public void setPlanosSaude(List<PlanoSaudeEntity> planoSaude) {
		this.planosSaude = planoSaude;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result + ((nome == null) ? 0 : nome.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ConvenioEntity other = (ConvenioEntity) obj;
		if (id != other.id)
			return false;
		if (nome == null) {
			if (other.nome != null)
				return false;
		} else if (!nome.equals(other.nome))
			return false;
		return true;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

}
